-
Notifications
You must be signed in to change notification settings - Fork 164
Add BitPack instance for Index 0
#2784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
martijnbastiaan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review together with @DigitalBrains1
Nice, this would get rid of a lot of unwanted 1 <= n constraints.
Add this fact to the typelits plugins.
I doubt reasoning about type families is in-scope for the plugins, but you might want to take that up with the maintainers :-).
I think we should change the cover letter's motivation to be something along the lines of "this aligns clash-the-compiler's thoughts on Index 0 with BitPack (Index 0)".
A changelog is needed, but that's also in the TODOs.
Other than that LGTUs.
|
It seems to still need something more though: Full messageExperienced with GHC 9.6.6. [edit] |
|
It's because of the new |
8510fbd to
2714056
Compare
|
I understand the desire to get rid of that But lets say someone is (accidentally) calling |
I don't think that this is the right way to look at it. Consider the following example: topEntity ::
HiddenClockResetEnable System =>
Signal System (Index 0)
topEntity = pure $ unpack @(Index 0) $ resize (0 :: BitVector 1)If that description is turned into Verilog with I agree that the user might end up with a run time error in simulation, if trying to inspect what comes out of applying Note that the type system never was intended to prevent us from this, in the same way as it cannot prevent us from ever having a look at the contents of |
2714056 to
0103c88
Compare
0103c88 to
8f922b8
Compare
DigitalBrains1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a full review yet; I'll wait until you have it working.
But browsing a bit I did notice you expanded the scope of the PR a lot. You've removed a lot of Index n, 1 <= n constraints even if they don't involve BitPack. If you want to address different cases of Index bounds as well, I think it's better treated in a new PR because it'll require some good thought.
For instance, you're removing the 1 <= n from the resetGlitchFilter functions, but now it is just completely broken:
>>> printX $ sampleN 10 $ unsafeFromReset $ resetGlitchFilter d2 systemClockGen resetGen
[True,True,True,True,True,False,False,False,False,False]
>>> printX $ sampleN 10 $ unsafeFromReset $ resetGlitchFilter d0 systemClockGen resetGen
[True,True,True,True,undefined,undefined,undefined,undefined,undefined,undefined]
Thanks for the quick feedback. I primarily was interested in observing which code may change and just wanted to get some feedback from CI. Unfortunately, there won't be any reasonable feedback without also hiding the warnings currently blocking #3061. I'll definitely have a closer look on all the introduced changes again. |
This PR gets rid of the additional
1 <= nconstraint for theBitPackinstance ofIndex n.Background:
Index 0andVoidare empty types → isomorphic to the empty setIndex 1and()are singleton types → isomorphic to a singleton setHence, we only need to question ourselves: how many bits do you need to distinguish between different elements of these types / sets? In both cases the answer clearly is: 0. Thus,
BitSize (Index 0) = 0.From another perspective: Clash generates valid HDL for
Index 0and the number of bits required by the generated HDL is zero as well. Hence, there is no reason to hide this fact in the type system for this particular case.Requires:
Still TODO: